package com.misoo.ex08;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.view.View.OnClickListener;

public class Ex08Activity extends Activity implements OnClickListener{
	private final int WC = ViewGroup.LayoutParams.WRAP_CONTENT;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        RelativeLayout r_layout = new RelativeLayout(this);
        setContentView(r_layout);
        TableLayout tableLayout = new TableLayout(this);
        r_layout.addView(tableLayout, new RelativeLayout.LayoutParams(WC,WC));
        tableLayout.setId(1);

        TableRow tableRow1 = new TableRow(this);
        tableLayout.addView(tableRow1, new TableLayout.LayoutParams(WC,WC));
        ImageView iv = new ImageView(this);
        tableRow1.addView(iv);
        iv.setImageDrawable(getResources().getDrawable(R.drawable.star_big_on));
        EditText edit1 = new EditText(this);
        tableRow1.addView(edit1);
        
        TableRow tableRow2 = new TableRow(this);
        ImageView iv2 = new ImageView(this);
        tableRow2.addView(iv2);
        iv2.setImageDrawable(getResources().getDrawable(R.drawable.gallery_photo_1));
        EditText edit2 = new EditText(this);
        tableRow2.addView(edit2);
        tableLayout.addView(tableRow2,new TableLayout.LayoutParams(WC,WC));
        
        Button btn = new Button(this);
        btn.setText("Exit");
        btn.setOnClickListener(this);
        RelativeLayout.LayoutParams param = 
        		new RelativeLayout.LayoutParams(WC,WC);
        param.addRule(RelativeLayout.BELOW,1);
        param.topMargin = 20;
        r_layout.addView(btn, param);
        
        
        //setContentView(R.layout.main);
    }
    public void onClick(View arg0){
    	finish();
    }
}